<template>
  <div class="app-container home">
    <el-row :gutter="20">
      <el-col :sm="24" :lg="12" style="padding-left: 20px">
        <h2>秋名山租车后台管理系统</h2>
      </el-col>
      <el-col :sm="24" :lg="12" style="padding-left: 50px">
        <el-row>
          <el-col :span="12">
            <h2></h2>
          </el-col>
        </el-row>
      </el-col>
    </el-row>
    <el-divider/>
    <el-row ::gutter="20">
      <div class="amap-wrapper">
        <el-amap class="amap-box" :vid="'amap-vue'" :zoom="zoom" :center="markers[0].position" >
          <el-amap-marker v-for="marker in markers" :position="marker.position" :title="marker.title"></el-amap-marker>
        </el-amap>
      </div>
    </el-row>

    <el-row :gutter="20">
      <el-col :xs="24" :sm="32" :md="32" :lg="12">
        <el-card class="update-log" width="100%">
          <div slot="header" class="clearfix">
            <span>用户反馈</span>
          </div>
          <el-collapse v-for="feedback in feedbackList" accordion>
            <el-collapse-item>
              <template slot="title">
                <i class="el-icon-alarm-clock"/>{{ parseTime(feedback.createTime, '{y}-{m}-{d}') }} ---
                <i class="el-icon-chat-line-round"/> {{ feedback.title }}
              </template>
              <el-descriptions class="margin-top" title="" :column="3" :size="size" border>
                <template slot="extra">
                  <el-button type="primary" size="small">处理反馈</el-button>
                </template>
                <el-descriptions-item>
                  <template slot="label">
                    <i class="el-icon-user"></i>
                    联系人
                  </template>
                  {{ feedback.username }}
                </el-descriptions-item>
                <el-descriptions-item>
                  <template slot="label">
                    <i class="el-icon-mobile-phone"></i>
                    手机号
                  </template>
                  {{ feedback.telephone }}
                </el-descriptions-item>
                <el-descriptions-item>
                  <template slot="label">
                    <i class="el-icon-location-outline"></i>
                    邮箱
                  </template>
                  {{ feedback.email }}
                </el-descriptions-item>
                <el-descriptions-item>
                  <template slot="label">
                    <i class="el-icon-office-building"></i>
                    反馈内容
                  </template>
                  <div class="ql-editor" v-html=feedback.content></div>
                </el-descriptions-item>
              </el-descriptions>
            </el-collapse-item>
          </el-collapse>
        </el-card>
      </el-col>
      <el-col :xs="24" :sm="32" :md="32" :lg="12">
        <!--        放个日历-->
        <el-calendar v-model="calendar">
        </el-calendar>
      </el-col>
    </el-row>
  </div>
</template>

<script>
import { listFeedback } from '@/api/ums/feedback'
import { workCount } from '@/api/workbench'
import eCharts from 'echarts'
import VueAMap from 'vue-amap'
import AmapShow from '@/views/amap/amapShow'
import { listStore } from '@/api/pms/store'

export default {
  name: 'Index',
  components: { AmapShow },
  data() {
    return {
      // 版本号
      version: '4.0.1',
      feedbackList: [],
      workCount: {},
      calendar: new Date(),
      chart: {},
      zoom: 8,
      zooms: [10, 22],
      events: {
        click: (e) => {
          this.mapClickCallback(e)
        }
      },
      markers: []
    }
  },
  created() {
    this.getFeedbackList()
    this.getWorkCount()
    this.getStoreMarkers()
  },
  mounted() {
    this.initCharts()
  },
  methods: {
    goTarget(href) {
      window.open(href, '_blank')
    },
    getFeedbackList() {
      listFeedback(this.queryParams).then(response => {
        this.feedbackList = response.data
      })
    },
    getWorkCount() {
      workCount().then(response => {
        this.workCount = response.data.data
      })
    },
    //初始化echarts
    initCharts() {
      this.chart = this.$echarts.init(document.getElementById('mycharts'))
      this.setOptions()
    },
    setOptions() {
      this.chart.setOption({
        tooltip: {},
        xAxis: {
          data: ['衬衫', '羊毛衫', '雪纺衫', '裤子']
        },
        yAxis: {},
        series: [{
          name: '销量',
          type: 'bar',
          data: this.workCount.map((count) => {
            return count.value
          })
        }]
      })
    },
    getStoreMarkers() {
      listStore().then(res => {
        const store = res.data
        store.forEach(item => {
          this.markers.push({
            position: [item.position.split(',')[0],item.position.split(',')[1]],
            title: item.storeName
          })
        })
      })
      console.log("markers",this.markers)
      console.log("center",this.center)
    }
  }
}
</script>

<style scoped lang="scss">
.home {
  blockquote {
    padding: 10px 20px;
    margin: 0 0 20px;
    font-size: 17.5px;
    border-left: 5px solid #eee;
  }

  hr {
    margin-top: 20px;
    margin-bottom: 20px;
    border: 0;
    border-top: 1px solid #eee;
  }

  .col-item {
    margin-bottom: 20px;
  }

  ul {
    padding: 0;
    margin: 0;
  }

  font-family: "open sans", "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 13px;
  color: #676a6c;
  overflow-x: hidden;

  ul {
    list-style-type: none;
  }

  h4 {
    margin-top: 0px;
  }

  h2 {
    margin-top: 10px;
    font-size: 26px;
    font-weight: 100;
  }

  p {
    margin-top: 10px;

    b {
      font-weight: 700;
    }
  }

  .update-log {
    ol {
      display: block;
      list-style-type: decimal;
      margin-block-start: 1em;
      margin-block-end: 1em;
      margin-inline-start: 0;
      margin-inline-end: 0;
      padding-inline-start: 40px;
    }
  }

  .amap-wrapper {
    width: 100%;
    height: 500px;
  }
}
</style>

